package com.zj.log.controller;

import com.zj.log.domain.Log;
import com.zj.log.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zj
 * @Date: 2019/2/3 21:49
 * @Description:
 */
@RestController
public class ServiceController {
    @Autowired
    LogService logService;

    @GetMapping("/createLog")
    public void createLog(@RequestParam(value = "logId",required = false,defaultValue ="") String logId,
                          @RequestParam(value = "username",required = false,defaultValue = "") String username,
                          @RequestParam(value = "userId",required = false,defaultValue ="") String userId,
                          @RequestParam(value = "type",required = false,defaultValue ="") Integer type,
                          @RequestParam(value = "description",required = false,defaultValue ="") String description,
                          @RequestParam(value = "action",required = false,defaultValue ="") String action,
                          @RequestParam(value = "method",required = false,defaultValue ="") String method,
                          @RequestParam(value = "ip",required = false,defaultValue ="") String ip,
                          @RequestParam(value = "userAgent",required = false,defaultValue ="") String userAgent,
                          @RequestParam(value = "param",required = false,defaultValue ="") String param,
                          @RequestParam(value = "exception",required = false,defaultValue ="") String exception,
                          @RequestParam(value = "createDate",required = false,defaultValue ="") String createDate) {

        Log log = new Log( logId, username, userId, type, description, action, method, ip, userAgent, param, exception, createDate );
        logService.saveOrUpdate( log );

    }
}
